# 打印当前文件夹下所有文件及子文件夹下的文件
import os
# 打印当前文件所在文件夹
print("当前文件所在文件夹为： "+os.getcwd())

path = os.getcwd()
print("当前文件夹下所有文件为："+str(os.listdir(path=path)))  # 打印当前文件夹下所有文件

l1 = os.listdir(r'C:\Users\wl\PycharmProjects\study\week1\week1')
show_list =[]


def get_file(list_file):
    for i in list_file:
        if os.path.isdir(r'C:\Users\wl\PycharmProjects\study\week1\week1'+'\\'+i):  # 判断是否是文件夹
            l2 = os.listdir(r'C:\Users\wl\PycharmProjects\study\week1\week1'+'\\'+i)
            get_file(l2)
        else:
            show_list.append(i)


get_file(l1)
# 打印当前文件夹下所有文件及子文件夹下的文件
print(r"C:\Users\wl\PycharmProjects\study\week1\week1"+"下的所有文件及子文件夹下的文件为: "+str(show_list))